package com.lms.dto;

import java.util.ArrayList;
import java.util.List;

import com.lms.domain.User;



public class UserMapper {

	public static UserDto map(User user) {
			UserDto dto = new UserDto();
			dto.setId(user.getId());
			dto.setFirstName(user.getFirstName());
			dto.setLastName(user.getLastName());
			dto.setUsername(user.getUsername());
			
			if(user.getRole() !=null && user.getRole().getRole() !=null)
			dto.setRole(user.getRole().getRole());
			if(user.getProject() !=null && user.getProject().getProject() !=null)
			dto.setProject(user.getProject().getProject());
			if(user.getTraining() !=null && user.getTraining().getTraining() !=null)
			dto.setTraining(user.getTraining().getTraining());
			
			return dto;
	}
	
	public static List<UserDto> map(List<User> users) {
		List<UserDto> dtos = new ArrayList<UserDto>();
		for (User user: users) {
			dtos.add(map(user));
		}
		return dtos;
	}
}
